package com.zyz.K_集合.Set接口实现类一HashSet;

import java.util.HashSet;
import java.util.Iterator;

/**
 * @author: vick
 * @Date: 2025/3/28
 * @Description:
 * @version: 1.0
 */
public class Demo1 {
    public static void main(String[] args) {
        HashSet<Integer> hashSet = new HashSet<>();
        hashSet.add(11);
        hashSet.add(12);
        hashSet.add(23);
        hashSet.add(14);
        hashSet.add(25);
        hashSet.add(11);
        hashSet.add(16);

        // 无需且不可重复
        System.out.println(hashSet);
        System.out.println("=======");
        Iterator<Integer> iterator = hashSet.iterator();
        while (iterator.hasNext()) {
            System.out.println(iterator.next());
        }
    }
}
